package book;
import java.io.Serializable;
/**
 *JavaBean类
 * 确定好书的属性
 *  还有一些基本的get set toString 和构造 方法
 */
public class Book implements Serializable {
    private int id;         //书的编号
    private String name;    //书名
    private String author;  //作者
    private double price;      //价格
    private String type;    //类别
    private int love;       //书的点赞量
    private int state;      //书的收藏量
    private boolean isBorrowed;//是否被借出，默认是false
    public Book(int id, String name, String author, double price, String type, int love, int state) {
        this.id = id;
        this.name = name;
        this.author = author;
        this.price = price;
        this.type = type;
        this.love = love;
        this.state = state;
    }
    public Book(int id, String name, String author, double price, String type, int love, int state,boolean isBorrowed) {
        this.id = id;
        this.name = name;
        this.author = author;
        this.price = price;
        this.type = type;
        this.love = love;
        this.state = state;
        this.isBorrowed = isBorrowed;
    }
    public Book() {
    }
    //用于书籍信息的打印
    @Override
    public String toString() {
        return "图书信息{" +
                "编号：" + id +"  "+
                "书名：" + name + "  " +
                "作者：" + author +"  "+
                "价格：" + price +"  "+
                "类别：" + type + "  " +
                "点赞量：" + love +"  "+
                "收藏量：" + state +"  "+
                ((isBorrowed)? "该书已借出" : "该书未借出") +
                '}';
    }
    //用于个人借阅记录的打印
    public String toString1() {
        return "图书信息{" +
                "编号：" + id +"  "+
                "书名：" + name + "  " +
                "作者：" + author +"  "+
                "价格：" + price +"  "+
                "类别：" + type + "  " +
                "点赞量：" + love +"  "+
                "收藏量：" + state +
                '}';
    }
    //用于写入文本
    public String toStringToFile() {
        return  id +","+
                name + "," +
                author +","+
                price +","+
                type + "," +
                love +","+
                state+","+
                isBorrowed;
    }
    public int getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public String getAuthor() {
        return author;
    }

    public double getPrice() {
        return price;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public int getLove() {
        return love;
    }

    public void setLove(int love) {
        this.love = love;
    }

    public int getState() {
        return state;
    }

    public void setState(int state) {
        this.state = state;
    }

    public boolean isBorrowed() {
        return isBorrowed;
    }

    public void setBorrowed(boolean borrowed) {
        isBorrowed = borrowed;
    }
}
